<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorate="~{layouts/layout}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <meta name="_csrf" th:content="${_csrf.token}"/>
    <meta name="_csrf_header" th:content="${_csrf.headerName}"/>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <title>订单管理系统</title>

    <link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="assets/stylesheets/pixel-admin.min.css" rel="stylesheet" type="text/css">
    <link href="assets/stylesheets/widgets.min.css" rel="stylesheet" type="text/css">
    <link href="assets/stylesheets/rtl.min.css" rel="stylesheet" type="text/css">
    <link href="assets/stylesheets/themes.min.css" rel="stylesheet" type="text/css">
    <style>
        .table-bordered th{
            text-align: center;
        }
        .table-bordered td{
            word-break:break-all; word-wrap:break-all;
        }
    </style>
</head>

<body class="theme-default main-menu-animated">

<script>var init = [];</script>
<th:block layout:fragment="content">
    <div class="col-xs-12 col-sm-12">
        <form action="?" th:object="${orderQo}" th:method="get">
            <div class="form-group">

                <div class="col-sm-4">
                    <input type="text" class="form-control" id="name" placeholder="请输入名称" th:field="*{username}"/>
                </div>
                <div class="col-sm-3">
                    <select  class="form-control" th:field="*{status}">
                        <option value="UNTREAD">未处理</option>
                        <option value="UNDISPATCHED">未发货</option>
                        <option value="DISPATCHED" selected="selected">已发货</option>
                        <option value="SIGNED">已签收</option>
                        <option value="COMFIRM">已确认</option>
                        <option value="REJECT">拒收</option>
                        <option value="WHATSCOMFIRM">短信确认</option>
                        <option value="WHATSCANCEL">短信撤单</option>
                        <option value="TELNOLINK">电话不通</option>
                        <option value="NOLINK">联系不上</option>
                        <option value="DONOT">不要了</option>
                        <option value="THINKING">考虑中</option>
                    </select>
                </div>
                <div class="col-sm-4">
                    <button class="btn btn-default" type="submit" placeholder="查询">查询</button>
                </div>
            </div>
        </form>
        <table id="ordertable" class="table table-bordered table-hover">
            <thead>
            <tr>
                <th>#</th>
                <th>单号</th>
                <th>订购时间</th>
                <th>产品名称</th>
                <th>规格</th>
                <th>型号</th>
                <th>联系人</th>
                <th>手机</th>
                <th>收货地址</th>
                <th>留言</th>
                <th>提交IP</th>
                <th>推荐人</th>
                <th>状态</th>
                <th>处理</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="order,inx :${datas.content}">
                <td th:text="${inx.index}">1</td>
                <td th:text="${order.id}">Mark</td>
                <td th:text="${#dates.format(order.getCreatedAt(),'yyyy-MM-dd HH:mm:ss')}"></td>
                <td th:text="${order.productname}"></td>
                <td th:text="${order.pricename}">Mark</td>
                <td th:text="${order.stylename}">Mark</td>
                <td th:text="${order.username}">1</td>
                <td th:text="${order.mobile}">1</td>
                <td th:text="${order.addr}">1</td>
                <td th:text="${order.message}">1</td>
                <td th:text="${order.ip}"></td>
                <td th:text="${order.purchase}"></td>
                <td>
                    <select th:id="${'select_'+order.id}">
                        <option th:each="state ,index : ${T(com.hubin.mode.enums.OrderStatus).values()}"
                                th:value="${state.name()}"
                                th:text="${state}"
                                th:selected="${state == order.status}"
                        >
                        </option>
                    </select>
                </td>
                <td>
                    <button  class="btn btn-info"  th:onclick="'javascript:editorder(this,'+${order.id}+');'" >修改</button> &nbsp;&nbsp;
                </td>
            </tr>

            </tbody>
        </table>

        <div th:include="~{layouts/page::pager}" th:remove="tag"></div>

    </div>

    <script>
        function editorder(o,id) {
            var status = $('#select_'+id).val();
            $.get('/order/editOrder',{status:status,id:id},function(res){
                $.growl.notice({ message: res});
            });
        }

    </script>
</th:block>


</body>
</html>